package com.example.pattern.chainOfResponsibility;

import com.example.pattern.chainOfResponsibility.entity.Request;
import com.example.pattern.chainOfResponsibility.impl.AuthorityHandler;
import com.example.pattern.chainOfResponsibility.impl.IdentifyHandler;
import com.example.pattern.chainOfResponsibility.impl.LoginHandler;

/**
 * 责任链模式
 *  1、请求的发送者和接受者解耦
 *  2、可以 执行顺序单元
 *  3、符合开闭原则和单一原则
 */
public class ChainTest {

    public static void main(String[] args) {

        Request request = new Request(false, false, false);
        LoginHandler handlers = new LoginHandler(new AuthorityHandler(new IdentifyHandler(null)));
        System.out.println("第一次处理");
        handlers.process(request);
        System.out.println("第二次处理");
        handlers.process(request);
    }

}
